package fragments.shopadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.travel.R;

import java.util.List;

import shopbean.ShopSearchBean;

/**
 * Created by Administrator on 2016/10/23.
 */
public class ShopSearchAdapter extends BaseAdapter {
    private List<ShopSearchBean.DataBean.HotPlacesBean> list;
    private Context context;

    public ShopSearchAdapter(List<ShopSearchBean.DataBean.HotPlacesBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view==null){
            view= LayoutInflater.from(context).inflate(R.layout.shop_search_gvitem,null);
            holder=new ViewHolder();
            holder.shop_search_tv= (TextView) view.findViewById(R.id.shop_search_tv);
            view.setTag(holder);
        }else {
            holder= (ViewHolder) view.getTag();
        }
        holder.shop_search_tv.setText(list.get(i).getCnName());
        return view;
    }
    static class  ViewHolder{
        TextView shop_search_tv;
    }
}
